﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ConnectToDatabase;

namespace QLGiayDep.Forms
{
    /// <summary>
    /// Interaction logic for FormBCDoanhThu.xaml
    /// </summary>
    public partial class FormBCDoanhThu : Page
    {
        SelectDB selectDB;
        DateTime m_dtTemp =new DateTime();
        string URL;

        public FormBCDoanhThu(string _URL)
        {
            InitializeComponent();
            URL = _URL;
            selectDB = (SelectDB)Activator.GetObject(typeof(SelectDB), URL + "SELECTDB_OBJECT");
        }

        private void btnBCDT_Click(object sender, RoutedEventArgs e)
        {
            if (dtmNgayBaoCao.SelectedDate == null)
                MessageBox.Show("Chưa chọn ngày báo cáo", "Thông Báo");
            else
            {
                m_dtTemp = dtmNgayBaoCao.SelectedDate.Value;
                dataBCDT.ItemsSource = selectDB.SelectAllSanPhamDaMuaTheoNgay(m_dtTemp.ToString("yyyy/MM/dd"));
            }
        }

        private void btnXuatFile_Click(object sender, RoutedEventArgs e)
        {

            m_dtTemp = dtmNgayBaoCao.SelectedDate.Value;
            int day = dtmNgayBaoCao.SelectedDate.Value.Day;
            int month = dtmNgayBaoCao.SelectedDate.Value.Month;
            int year = dtmNgayBaoCao.SelectedDate.Value.Year;
            ExportExcel.exportExcel("Danh Sách Sản Phẩm Bán Trong Ngày " + day + "/" + month + "/" + year, selectDB.SelectAllSanPhamDaMuaTheoNgay_DataSet(m_dtTemp.ToString("yyyy/MM/dd")));
        }
    }
}
